feat(deploy): add shared check-published-deploy-constants script#238
feat(deploy): add shared check-published-deploy-constants script#238thedavidmeister wants to merge 2 commits into
Conversation
Parameterizes the deploy-constants completeness check that raindex
currently hardcodes in script/check-published-deploy-constants.sh.
Exposes check-published-deploy-constants on sol-shell PATH so any
consumer repo can run it via:
nix develop github:rainlanguage/rainix#sol-shell \
-c check-published-deploy-constants <pkg> <lib.sol> <PREFIX1> ...
Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new parameterized shell script ChangesDeploy Constants Completeness Check
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…dInputs list Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/check-published-deploy-constants.sh`:
- Around line 26-29: The argument validation in check-published-deploy-constants
should follow the same success-only CLI contract as the rest of the script, so
replace the early failure exit with a zero-status path that emits one of the
allowed statuses instead of aborting. Update the main guard around the usage
check and any caller-facing output so the script never returns a nonzero code
for this case, keeping the observable results limited to OK, MISSING, or SKIP.
- Around line 35-42: The version lookup in check-published-deploy-constants.sh
is treating parse failures the same as fetch failures because the `versions`
pipeline ends with `|| true`, so `grep`/`cut` empties fall through to the `SKIP`
branch. Update the shell logic around the `curl`/`grep`/`cut` pipeline so only
real connectivity/request failures are ignored, while malformed or unexpected
API responses are detected separately and reported as a parse/API drift issue
instead of `SKIP`; use the existing `versions` assignment and the `if [ -z
"$versions" ]` check to split these cases clearly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b2d7aea4-4d8e-440f-81a9-ac59b36215bc
📒 Files selected for processing (3)
flake.nixlib/check-published-deploy-constants.shtest/bats/devshell/sol-shell/sol-tasks.test.bats
| if [ "$#" -lt 3 ]; then | ||
| printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2 | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep the CLI contract success-only here too.
The linked issue/PR contract says callers should only see OK, MISSING, or SKIP and a zero exit status. exit 1 adds a fourth behavior that can break consumers wiring this into CI.
Proposed fix
if [ "$#" -lt 3 ]; then
- printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2
- exit 1
+ printf 'SKIP: usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n'
+ exit 0
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [ "$#" -lt 3 ]; then | |
| printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2 | |
| exit 1 | |
| fi | |
| if [ "$#" -lt 3 ]; then | |
| printf 'SKIP: usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' | |
| exit 0 | |
| fi |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lib/check-published-deploy-constants.sh` around lines 26 - 29, The argument
validation in check-published-deploy-constants should follow the same
success-only CLI contract as the rest of the script, so replace the early
failure exit with a zero-status path that emits one of the allowed statuses
instead of aborting. Update the main guard around the usage check and any
caller-facing output so the script never returns a nonzero code for this case,
keeping the observable results limited to OK, MISSING, or SKIP.
| versions=$( | ||
| curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \ | ||
| | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u | ||
| ) || true | ||
|
|
||
| if [ -z "$versions" ]; then | ||
| printf 'SKIP: could not fetch published soldeer versions' | ||
| exit 0 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Don't collapse parse failures into a connectivity SKIP.
Because || true is attached to the whole pipeline, any successful fetch that produces no grep matches also lands in SKIP: could not fetch.... That masks parser/API drift as a benign skip.
Proposed fix
-versions=$(
- curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \
- | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u
-) || true
-
-if [ -z "$versions" ]; then
+response=$(curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null) || {
printf 'SKIP: could not fetch published soldeer versions'
exit 0
-fi
+}
+
+versions=$(
+ printf '%s' "$response" \
+ | grep -oE '"version":"[0-9][0-9.]*"' \
+ | cut -d'"' -f4 \
+ | sort -u
+)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| versions=$( | |
| curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \ | |
| | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u | |
| ) || true | |
| if [ -z "$versions" ]; then | |
| printf 'SKIP: could not fetch published soldeer versions' | |
| exit 0 | |
| response=$(curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null) || { | |
| printf 'SKIP: could not fetch published soldeer versions' | |
| exit 0 | |
| } | |
| versions=$( | |
| printf '%s' "$response" \ | |
| | grep -oE '"version":"[0-9][0-9.]*"' \ | |
| | cut -d'"' -f4 \ | |
| | sort -u | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lib/check-published-deploy-constants.sh` around lines 35 - 42, The version
lookup in check-published-deploy-constants.sh is treating parse failures the
same as fetch failures because the `versions` pipeline ends with `|| true`, so
`grep`/`cut` empties fall through to the `SKIP` branch. Update the shell logic
around the `curl`/`grep`/`cut` pipeline so only real connectivity/request
failures are ignored, while malformed or unexpected API responses are detected
separately and reported as a parse/API drift issue instead of `SKIP`; use the
existing `versions` assignment and the `if [ -z "$versions" ]` check to split
these cases clearly.
Closes #236
Adds a parameterized
check-published-deploy-constantsscript tolib/and exposes it onsol-shellPATH. Consumers (raindex, rain.math.float, etc.) can drop their bespoke copies and call the shared version via:The script queries the soldeer registry for all published versions of the named package, then asserts
<PREFIX>_{ADDRESS,CODEHASH}_<ver>constants exist in the given Solidity file. Exits 0 in all cases; printsOK,MISSING: <names>, orSKIP: <reason>(if the registry is unreachable).Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit